function isPlainObject(obj) {
    if (typeof obj !== 'object' || obj === null) {
        return false;
    }

    let proto = obj;
    while (Object.getPrototypeOf(proto)){ //proto.__proto__
        proto = Object.getPrototypeOf(proto);
    }

    return Object.getPrototypeOf(obj) === proto;
}

/*
let obj = {name: 'ahhh'}; //new Object Object.prototype === Object.prototype
console.log(isPlainObject(obj)); //true

function P(){}
let p = new P(); //P.prototype === Object.prototype 故↓
console.log(isPlainObject(p)); //false
*/

export default isPlainObject;
